<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>东东推登录</title>
<link href="../static/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="../static/css/common.css" rel="stylesheet">
<link href="../static/css/login.css" rel="stylesheet">
</head>
<body class="bodyb-color">
<div class="container-fluid bodyb-color" >
	<div class=" container-fluid heardb-color">
		<div class="container" style="padding-top: 1.2%;padding-bottom: 1.3%;">
			<img src="../static/images/logo1.png" onclick="javascript:window.location.href='index.html'" />
			<p class="navbar-text navbar-right heard-text" onclick="javascript:window.location.href='register.html'">没有账号？立即注册 </p>
		</div>
	</div>
	<div class="container-fluid">
		<div class="login-con login">
			<p class="ddt-bt text-center"><strong style="font-size: 26px">登录</strong></p>
			<form class="form-horizontal">
			  <div class="form-group">
			  	<div class="col-sm-12">
			    	<input type="text" class="form-control" id="phone" placeholder="用户名" maxlength="11">
			    	<span id="helpBlock" class="help-block">　</span>
			    </div>
			  </div>
			  <div class="form-group">
			  	<div class="col-sm-12">
			    	<input type="password" class="form-control" id="pwd" placeholder="密码" maxlength="16">
			    	<span id="helpBlock" class="help-block">　</span>
			    </div>
			  </div>
			  <button type="button" class="btn btn-default ddt-btn from-btn" id="ddtLogin">登录</button>
			</form>
			<div class="row">
				<div class="col-xs-6">
					<p class="text-left login-forgetPs" onclick="javascript:window.location.href='register.html'">立即注册</p>
				</div>
				<div class="col-xs-6">
					<p class="text-right login-forgetPs" onclick="javascript:window.location.href='getbackPw.html'">忘记密码</p>
				</div>
			</div>
			
		</div>
		<p class="text-center copyright">Copyright © 2014 - <h class='shi' style='font-size: 14px;'></h> 京ICP备18006432号-1</p>
	</div>
	
</div>
<script src="../static/js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="../static/bootstrap-3.3.7/js/bootstrap.min.js" type="text/javascript"></script>
<script src="../static/js/config.js" type="text/javascript"></script>
<script>
	$(document).ready(function(){
		var myDate = new Date();
			//获取当前年
			var year=myDate.getFullYear();
			$('.shi').text(year)
		
		$("#ddtLogin").click(function(){
			/* 调用登录方法 */
			
			if($('#phone').val() != "" || $('#pwd').val() !=""){
				$.ajax({
					type:"post",
					url:C.interface.login,
					dateType:"json",
					data:{
						phone : $("#phone").val(),
						pwd : $("#pwd").val(),
						appId : "gzh"
					},
					async:true,
					success:function(data){
						
						var url =window.location.href.replace('/html/login.html','/')
						console.log(url)
						/*手机号已经存在*/
						if(data.code == "10000"){
							//successHint($("#phone"));
							localStorage.setItem('token',data.data.token);
							localStorage.setItem('userid',data.data.userid);
							window.location = url+'index.html';
//							window.location = url+'index.html?userId='+data.data.userid+''; /*成功跳转*/
							
						}else{
							errorHint($("#phone"),data.msg);
						}
					}
				});
			}else{
			}
		});
		
		/*成功提示*/
		function successHint(valStr){
			var valStrOjb = valStr.parent().parent(); 
			valStrOjb.removeClass("has-error");
	    	valStrOjb.find(".error").addClass("none");
	    	valStrOjb.find(".help-block").text("　");
	    	
	    	valStrOjb.addClass("has-success");
	    	valStrOjb.find(".success").removeClass("none");
	    	valStrOjb.find(".help-block").text("　");
		}
		
		/*错误提示*/
		function errorHint(valStr,text){
			var valStrOjb = valStr.parent().parent(); 
			var valStrId = valStr.attr("id") ; 
			
			valStrOjb.removeClass("has-success");
			valStrOjb.find(".success").addClass("none");
	    	valStrOjb.addClass("has-error");					
	    	valStrOjb.find(".error").removeClass("none");
	    	
	    	valStrOjb.find(".help-block").text(text);
		}
		
	});
</script>
</body>
</html>